package ext.csc.component.numbergen.number;

import ext.csc.component.numbergen.bean.RequestInfoContained;
import ext.csc.component.numbergen.classification.ClassificationInfoContained;
import ext.csc.component.numbergen.rule.RuleInfoContained;

public class NumberGenerator {
	private ClassificationInfoContained classification;
	private RuleInfoContained rule;
	private RequestInfoContained rb;
	
	public NumberGenerator(ClassificationInfoContained classification, RuleInfoContained rule, RequestInfoContained rb){
		this.classification = classification;
		this.rule = rule;
		this.rb = rb;
	}
	
	public FormatedNumber generateNumber(){
		FormatedNumber result = new FormatedNumber();
		result.setClassification((ClassificationInfoContained) classification);
		result.setDateTime(rb.getDatetime());
		result.setRequestDesc(rb.getRequestdesc());
		result.setRequestor(rb.getRequestor());
		
		String ruleFormat = rule.getRuleformat();
		String numberFormat = ruleFormat.replaceAll("<ClassificationValue>", classification.getObjectclassvalue());
		
		result.setValue(numberFormat);
		
		return result;
	}
}
